package 集合;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Emp implements Comparable{
    String name;
    int age;
    String gender ;
    double salar;
    public Emp() {
    }
    public Emp(String name, int age, String gender, double salar) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.salar = salar;
    }

    public Emp(String s) {
    }
    public Emp(String s,int i) {
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getGender() {
        return gender;
    }
    public void setGender(String gender) {
        this.gender = gender;
    }
    public double getSalar() {
        return salar;
    }
    public void setSalar(double salar) {
        this.salar = salar;
    }
    @Override
    public String toString() {
        return "name=" + name  + ", age=" + age + ", gender=" + gender  + ", salar=" + salar ;
    }
    @Override
    public int compareTo(Object o) {
        if(o instanceof Emp){
            Emp oo=(Emp)o;
            return -this.age+(oo.age);
        }
        return 0;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Emp emp = (Emp) o;
        return age == emp.age &&
                Double.compare(emp.salar, salar) == 0 &&
                Objects.equals(name, emp.name) &&
                Objects.equals(gender, emp.gender);
    }
    @Override
    public int hashCode() {
        return Objects.hash(name, age, gender, salar);
    }
    public static List<Emp> getEmp(){
        ArrayList<Emp> list = new ArrayList<>();
        list.add(new Emp("马云",99,"小学",0));
        list.add(new Emp("马化腾",1,"幼儿园",1200000));
        list.add(new Emp("任贤齐",36,"中学",999));
        list.add(new Emp("冯巩",15,"高中",9998));
        list.add(new Emp("赵丽蓉",98,"小学",6126));
        list.add(new Emp("成龙",61,"初中",7812));
        list.add(new Emp("李连杰",48,"大学",1200));
        list.add(new Emp("周星驰",54,"大专",10002));
        return list;
    }
}
